// register.cpp

#include "register.h"
#include "user.h"
#include "user_io.h"
#include "crypto.h"

bool registerUser(const std::string& username, const std::string& password) {
    for (const User& user : load_users) {
        if (user.username == username) {  //防止username重复
            return false;
        }
    }

    std::string encryptedPassword = encryptDecrypt(password);
    User newUser { username, encryptedPassword };
    users.push_back(newUser);
    saveUsersToFile("D:\\QT_projects\\Login\\1.txt");
    return true;
}


